import service from '/@/utils/request';

export const usePosCategoryCreateApi = (formData: object) => {
    return service({
        url: `v0/pos/category/create`,
        method: 'POST',
        data: formData
    });
}

export const usePosCategoryQueryApi = (code: string,) => {
    return service({
        url: `v0/pos/category/query`,
        method: 'GET',
        params: { code: code },
    });
}

export const usePosCategoryListApi = () => {
    return service({
        url: `v0/pos/category/list`,
        method: 'GET',
    });
}

export const usePosCategoryPageApi = (formData?: object) => {
    return service({
        url: `v0/pos/category/page`,
        method: 'POST',
        data: formData
    });
}

export const usePosCategoryDeleteApi = (param: string | string[]) => {
    let arrList: string[] = []

    if (param instanceof Array) {
        arrList = param
    } else {
        arrList.push(param)
    }

    return service({
        url: `v0/pos/category/delete`,
        method: 'DELETE',
        data: { codeList: arrList }
    });
}

export const usePosCategoryUpdateApi = (formData: object) => {
    return service({
        url: `v0/pos/category/update`,
        method: 'PUT',
        data: formData
    });
}

export const usePosCategoryExportApi = (formData?: object) => {
    return service({
        url: `v0/pos/category/export`,
        method: 'POST',
        data: formData
    });
}

// 设备
export const useCategoryRuleRemoveDeviceApi = (formData: object) => {
    return service({
        url: `v0/pos/rule/removeDevice`,
        method: 'DELETE',
        data: formData
    });
}

export const useCategoryRuleDevicePageApi = (formData?: object) => {
    return service({
        url: `v0/pos/rule/devicePage`,
        method: 'POST',
        data: formData
    });
}

export const useCategoryRuleAddDeviceApi = (formData: object) => {
    return service({
        url: `v0/pos/rule/addDevice`,
        method: 'POST',
        data: formData
    });
}